package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.*;
import com.acme.bankapp.domain.client.*;
import com.acme.bankapp.domain.account.*;
import com.acme.bankapp.exceptions.ClientExistsException;

import java.util.List;

public class BankService {

    public static Bank createNewBank(){
        return new Bank();
    }

    public static Bank createNewBank(List<ClientRegistrationListener> clientRegistrationListenerList){
        return new Bank(clientRegistrationListenerList);
    }


    public static void addClient(Bank bank, Client client) throws ClientExistsException {
        bank.addClient(client);
    }

    public static Client addClient(Bank bank, String name, Gender gender) throws ClientExistsException {
        Client client = new Client(name, gender);
        bank.addClient(client);
        return client;
    }

    public static void printBalance(Bank bank) {
        System.out.println("printBalance");
        for (Client client: bank.getClients()) {
            System.out.println(client);
        }
    }

    public static void printMaximumAmountToWithdraw(Bank bank){
        System.out.println("printMaximumAmountToWithdraw");
        for (Client client: bank.getClients()) {
            for (Account account: client.getAccounts()) {
                System.out.println(client.getClientSalutation() + " : " + account + " : " + account.maximumAmountToWithdraw());
            }
        }

    }
}
